package com.rerun.common.quartz;

import com.rerun.entity.quartz.QrtzSchedulerState;
import org.quartz.SchedulerException;

import java.util.List;

/**
 * The interface Quartz manager.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /10/24 11:39
 */
public interface QuartzManager {

    List<QrtzSchedulerState> getAllQuartzInstances();

    /**
     * 获取所有任务.
     *
     * @return the all jobs
     * @throws SchedulerException the scheduler exception
     */
    List<QuartzJobBean> getAllJobs() throws SchedulerException;

    /**
     * 获取单个任务.
     *
     * @param jobName      the job name
     * @param jobGroupName the job group name
     * @return the job
     */
    QuartzJobBean getJob(String jobName, String jobGroupName) throws SchedulerException;

    /**
     * 获取所有正在执行的任务.
     *
     * @return the running jobs
     * @throws SchedulerException the scheduler exception
     */
    List<QuartzJobBean> getRunningJobs() throws SchedulerException;

    /**
     * 添加任务.
     *
     * @param jobBean the job bean
     * @throws ClassNotFoundException the class not found exception
     */
    void addJob(QuartzJobBean jobBean) throws ClassNotFoundException;

    /**
     * 修改任务时间.
     *
     * @param jobBean the job bean
     */
    void modifyJobCron(QuartzJobBean jobBean);

    /**
     * 移除任务.
     *
     * @param jobBean the job bean
     */
    void removeJob(QuartzJobBean jobBean);

    /**
     * 暂停任务.
     *
     * @param jobName      the job name
     * @param jobGroupName the job group name
     */
    void pauseJob(String jobName,String jobGroupName);

    /**
     * 暂停所有.
     */
    void pauseAllJobs();

    /**
     * 等执行的任务结束后 下线.
     */
    void shutdownAllJobs();

    /**
     * 强制下线.
     */
    void forceShutdownAllJobs();

    /**
     * 恢复任务.
     *
     * @param jobName      the job name
     * @param jobGroupName the job group name
     */
    void resumeJob(String jobName, String jobGroupName);

    /**
     * 恢复所有任务.
     */
    void resumeAllJobs();
}
